﻿<%@ Page Language="C#" %>
<%
    Response.ContentType = "text/xml";
    string nmsp = "http://www.opengis.net/kml/2.2";
   System.Net.WebRequest webReq = System.Net.HttpWebRequest.Create(Server.UrlDecode(Request.Params["endpoint"]));
    System.IO.Stream ReceiveStream = webReq.GetResponse().GetResponseStream();
    System.IO.StreamReader sr = new System.IO.StreamReader(ReceiveStream);
    string resultstring = sr.ReadToEnd();
    System.Xml.XmlDocument xmlDoc = new System.Xml.XmlDocument();
    xmlDoc.LoadXml(resultstring);
    System.Xml.XmlNamespaceManager nsmgr = new System.Xml.XmlNamespaceManager(xmlDoc.NameTable);
    nsmgr.AddNamespace("wms", nmsp);
    System.Xml.XmlNodeList list = xmlDoc.SelectNodes("//wms:description",nsmgr);
    foreach (System.Xml.XmlNode node in list)
    {
        string innertext = node.InnerText;
        int index = innertext.IndexOf("BUILDID");
        index = innertext.IndexOf("330", index);
        string name = innertext.Substring(index, 104 - 87);
        node.ParentNode.SelectSingleNode("wms:name", nsmgr).InnerText = name;
        node.InnerText = "<IFrame width=\"400px\" height=\"400px\" src=\"aspx/showinfo.aspx?name=$[name]\"></IFrame>";
    }
    Response.Write(xmlDoc.OuterXml);
     %>